import { createStoreBindings } from 'mobx-miniprogram-bindings'
import { store } from '@/utils/store'
import { call } from '@/utils/request'
import { showMsg, showLoading, hideLoading, showSuccess  } from '@/utils/toast'


Page({
  data: {
  },
  onLoad() {
  },
  onUnload() {
  },
  logout() {
    showLoading()
    call('/logout').then(res => {
      hideLoading()
      store.set_user_info({}, true)
      wx.navigateBack()
    })
  },
  destroyUser() {
    wx.showModal({
      title: '温馨提示',
      content: '注销后您的所有信息会在72小时内全部彻底删除！',
      success (res) {
        if (res.confirm) {
          showLoading()
          call('/destroyUser').then(res => {
            const duration = showSuccess("注销成功！")
            store.set_user_info({}, true)
            setTimeout(()=>{
              wx.navigateBack()
            }, duration)
          })
        }
      }
    })
  }
})
